<?php
/**
 * class App_Filter_Textarea
 *
 * @author kim
 */
class App_Filter_Textarea extends Zend_View_Helper_Abstract
{
    /**
     * filter the textarea's content
     *
     * @param  string $text - the text to be filter
     * @return string
     */
    static public function filter($text)
    {
        $text = preg_replace('/[\n\r]/', ' ', $text);
        $text = preg_replace('/\s+/', ' ', $text);
        $text = preg_replace('/\<br\>/i', "\n\n", $text);
        return $text;

        /*
        $text = preg_replace("/\t/"," ",$text);
        $text = preg_replace("/\r/","\n",$text);
        $text = preg_replace("/\n\s+\n/","\n\n",$text);
        $text = str_replace("\n\n","DOUBLECR",$text);
        $text = preg_replace("/[\n\r]/","",$text);
        $text = preg_replace("/DOUBLECR/","\n\n",$text);
        return $text;
        */
    }
}